<?php

declare(strict_types=1);

namespace App\Model;

use Hyperf\DbConnection\Model\Model;

/**
 *  切换主播记录
 */
class ChangeHostLog extends Model
{
    protected $table = 'change_host_log';

    /**
     * 加记录
     */
    static function addLog($userId = 0, $hostId = 0, $from = VoiceCall::FROM_NEW)
    {
        if (!$userId) return 0;
        $model = new self();
        $model->user_id = $userId;
        $model->host_id = $hostId;
        $model->from = $from;
        return $model->saveOrFail() ? 1 : 0;
    }
}
